$(function () {
    //等待加载
    loading();
    ajaxbankInfo();
});

/**
 * 加载用户已绑定的银行卡列表
 */
function ajaxbankInfo() {
    var url = "/Lvscore_User_M/account/ajaxbankInfo";
    $.post(
        url,
        function (data) {
            $("#info").empty();
            $.each(data, function (i, e) {
                $("#info").append(
                    '<div  class="card border_radius inline-block">' +
                    '<div class="cardInfm border_radius">' +
                    '<img src="' + getImgSrc(e.userAccount.bankName) + '" alt="" title="" class="marginLeft banklogo">' +
                    '<div class="right marginRight">' +
                    '尾号&nbsp;:&nbsp;<span>' + e.showAccountNum + '</span>' +
                    '<span class="creditCard marginRight">' + getAccountType(e.userAccount.accountType) + '</span>' +
                    '</div>' +
                    '</div>' +
                    '<div class="fastPay">' +
                    '<img src="/Lvscore_User_M/userWeb/static/images/faster.png" alt="" title="" class="marginLeft">' +
                    '<div class="right marginRight">' +
                    '<span>已开通</span>' +
                    '<a href="/Lvscore_User_M/userWeb/views/accounterCenter/cardDetail.html?aId=' + e.userAccount.id + '" class="marginRight">管理</a>' +
                    '</div>' +
                    '</div>' +
                    '</div>'
                );
            });
            $("#info").append(
                '<div class="card border_radius inline-block" align="center">' +
                '<a href="/Lvscore_User_M/userWeb/views/accounterCenter/addCard.html" title=""   alt="" style="width:110px;height:140px;display:block;margin:10px auto;">' +
                '<img src="/Lvscore_User_M/userWeb/static/images/addBank.png" alt="" title="" class="addCard"></br>' +
                '<span style="display:block;font-size:15px;color:#93BDF9;padding-top:10px; margin-right: 0px">添加银行卡</span>' +
                '</a>' +
                '</div>');
            //等待加载的效果消失
            $(".loadingBox").hide();
        }, "json");
}

function getAccountType(t) {
    if (t == 'null' || t == null)
        return '';
    else if (t == '0')
        return '信用卡';
    else if (t == '1')
        return '储蓄卡';
    else
        return '其他类型';
}
function getImgSrc(str) {
    if (str == "中国建设银行") {
        return '/Lvscore_User_M/userWeb/static/images/constructionBank_01.png';
    } else if (str == "中国邮政储蓄银行") {
        return '/Lvscore_User_M/userWeb/static/images/chinaEmail_01.png';
    } else if (str == "中国银行") {
        return "/Lvscore_User_M/userWeb/static/images/bankOfChina_01.png";
    } else if (str == "招商银行") {
        return "/Lvscore_User_M/userWeb/static/images/merchants_01.png";
    } else if (str == "浦发银行") {
        return "/Lvscore_User_M/userWeb/static/images/SPDbannk_01.png";
    } else if (str == "中国农业银行") {
        return "/Lvscore_User_M/userWeb/static/images/agriculturalBank_01.png";
    } else if (str == "中国工商银行") {
        return "/Lvscore_User_M/userWeb/static/images/business_01.png";
    } else if (str == "中信银行") {
        return "/Lvscore_User_M/userWeb/static/images/CITICbank_01.png";
    } else if (str == "兴业银行") {
        return "/Lvscore_User_M/userWeb/static/images/xingye.png";
    }else if (str == "平安银行") {
        return "/Lvscore_User_M/userWeb/static/images/safety_01.png";
    }
}